const phoneReg = /^1[0-9]{10}$/;
const passReg = /^[A-Za-z0-9]{6,12}$/;
export const validatePhone = (rule, value, callback) => {
  if (!value || value === "") {
    callback(new Error("请输入手机号"));
  } else if (!phoneReg.test(value)) {
    callback(new Error("请输入正确的手机号"))
  } else {
    callback();
  }
}

export const validateNewPhone = (rule, value, callback) => {
  if (!value || value === "") {
    callback(new Error("请输入新手机号"));
  } else if (!phoneReg.test(value)) {
    callback(new Error("请输入正确的手机号"))
  } else {
    callback();
  }
}

export const validatePass = (rule, value, callback) => {
  if (!value || value === "") {
    callback(new Error("请输入密码"));
  } else if (value.length < 6) {
    callback(new Error("密码过短"))
  } else if (value.length > 12) {
    callback(new Error('密码过长'))
  } else if (!passReg.test(value)) {
    callback(new Error("只能输入数字或字母"))
  } else {
    callback();
  }
}
